<?php

    function getfile($pic){




        //print_r($pic);die;
        $pic_name =$pic['name'];
        $file_path = $pic['tmp_name'];
        $up_path = './uploads/'.date('Y-m').'/'.date('d').'/';
        $max_size = 1204*1024*2;

        $ipos = stripos($pic['type'],'/');
        $type = substr($pic['type'], $ipos+1);

        if(!file_exists($up_path)){
            mkdir($up_path,777,true);
        }
        $allow_type = array('jpg','jpeg','gif','png');

        $filename = date('y-m-d').rand(10000,99999).'.'.$type;

        $url =$up_path.$filename;

        if (in_array($type,$allow_type)){
            if ($pic['size'] <= $max_size){
                move_uploaded_file($file_path,$url);
            }else{
                echo '<script type="text/javascript">alert("图片不能超过2M！");history.go(-1);</script>';die;
            }
        }else{
            echo '<script type="text/javascript">alert("文件类型不符合！");history.go(-1);</script>';die;
        }

        $thu_url = thumb($up_path,$filename);

        return array('pic' => $pic_name,'url' => $thu_url);

    }




?>